package datastruct;

import java.util.Vector;

public class Table {
	public enum TABLETYPE {TABLE, VIEW, SYSTEM_TABLE, GLOBAL_TEMPORARY, LOCAL_TEMPORARY, ALIAS, SYNONYM};
	private Vector<Column>		columns;
	private Vector<Relation>	relations;
	private Vector<Index>		indexes;
	private String				name;
	private String				type;
	
	public Table()
	{
		super();
		init();
	}
	
	public Table(String name)
	{
		super();
		this.name=name;
		this.type=null;
		init();
	}
	
	public Table(String name, String type)
	{
		super();
		this.name=name;
		this.type=type;
		init();
	}
	
	private void init()
	{
		this.columns=new Vector<Column>();
		this.relations=new Vector<Relation>();
		this.indexes=new Vector<Index>();
	}
	
	public Vector<Relation> getRelations()
	{
		return relations;
	}
	
	public Vector<Column> getColumns()
	{
		return columns;
	}
	
	public Vector<Index> getIndexes()
	{
		return indexes;
	}
	
	public String getName()
	{
		return this.name;
	}
	
	public Index getIndex(String name)
	{
		System.out.println("In cerca dell'indice:" + name);
		for(int i=0;i<indexes.size();i++)
		{
			String idxName = indexes.get(i).getName();
			System.out.println("indice corrente:" + idxName);
			if(idxName.equalsIgnoreCase(name))
				return indexes.get(i);
		}
		return null;
	}
	
}
